home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / ListSpinnerBeanInfo.java < prev    next >
Text File  |  1998-08-21  |  5KB  |  157 lines

  1. package symantec.itools.awt.util.spinner;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5. import java.util.ResourceBundle;
  6.  
  7. //  09/11/97    LAB    Removed redundant orientation and editable properties and connections
  8. //                    (Addresses Mac Bug #7820).
  9. //  08/19/98    LAB    Moved to GroupAWTAdditions folder.
  10.  
  11. /**
  12.  * BeanInfo for ListSpinner.
  13.  *
  14.  */
  15. public class ListSpinnerBeanInfo extends SimpleBeanInfo {
  16.  
  17.     /**
  18.      * Constructs a ListSpinnerBeanInfo object.
  19.      */
  20.     public ListSpinnerBeanInfo() {
  21.     }
  22.  
  23.     /**
  24.      * Gets a BeanInfo for the superclass of this bean.
  25.      * @return BeanInfo[] containing this bean's superclass BeanInfo
  26.      */
  27.     public BeanInfo[] getAdditionalBeanInfo() {
  28.         try {
  29.             BeanInfo[] bi = new BeanInfo[1];
  30.             bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
  31.             return bi;
  32.         }
  33.         catch (IntrospectionException e) { throw new Error(e.toString());}
  34.     }
  35.  
  36.     /**
  37.      * Gets the SymantecBeanDescriptor for this bean.
  38.      * @return an object of type SymantecBeanDescriptor
  39.      * @see symantec.itools.beans.SymantecBeanDescriptor
  40.      */
  41.     public BeanDescriptor getBeanDescriptor() {
  42.         ResourceBundle group = ResourceBundle.getBundle("symantec.itools.resources.GroupBundle");
  43.         String s=group.getString("GroupAWTAdditions"); 
  44.  
  45.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  46.         bd.setCanAddChild(false);
  47.         bd.setFolder(s);
  48.         bd.setToolbar(s);
  49.         bd.setWinHelp("0x123A4");
  50.  
  51.         bd.addAdditionalConnections(getAdditionalBeanInfo());
  52.  
  53.         return (BeanDescriptor) bd;
  54.     }
  55.  
  56.     /**
  57.      * Gets an image that may be used to visually represent this bean
  58.      * (in the toolbar, on a form, etc).
  59.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  60.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  61.      * @return an image for this bean, always color even if requested monochrome
  62.      * @see BeanInfo#ICON_MONO_16x16
  63.      * @see BeanInfo#ICON_COLOR_16x16
  64.      * @see BeanInfo#ICON_MONO_32x32
  65.      * @see BeanInfo#ICON_COLOR_32x32
  66.      */
  67.     public java.awt.Image getIcon(int iconKind) {
  68.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  69.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  70.             java.awt.Image img = loadImage("ListSpinnerC16.gif");
  71.             return img;
  72.         }
  73.  
  74.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  75.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  76.             java.awt.Image img = loadImage("ListSpinnerC32.gif");
  77.             return img;
  78.         }
  79.  
  80.         return null;
  81.     }
  82.  
  83.     /**
  84.      * Gets an array of descriptions of the methods used for "connections" by
  85.      * Visual CafΘ's Interaction Wizard.
  86.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  87.      * @return method descriptions for this bean
  88.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  89.      */
  90.     public MethodDescriptor[] getMethodDescriptors() {
  91.         Class[] args;
  92.         ConnectionDescriptor connection;
  93.         java.util.Vector connections;
  94.         java.util.Vector md = new java.util.Vector();
  95.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  96.  
  97.         try{
  98.             args = new Class[1];
  99.             args[0] = java.lang.String.class ;
  100.             MethodDescriptor addItem = new MethodDescriptor(beanClass.getMethod("addItem", args));
  101.             connections = new java.util.Vector();
  102.             connection = new ConnectionDescriptor("input", "String", "",
  103.                                     "%name%.addItem(%arg%);",
  104.                                     conn.getString("addItemSpinner"));
  105.             connections.addElement(connection);
  106.  
  107.             addItem.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  108.             md.addElement(addItem);
  109.         } catch (Exception e) { throw new Error("addItem:: " + e.toString()); }
  110.  
  111.         try{
  112.             args = null;
  113.             MethodDescriptor getCurrentText = new MethodDescriptor(beanClass.getMethod("getCurrentText", args));
  114.  
  115.             connections = new java.util.Vector();
  116.             connection = new ConnectionDescriptor("output", "String", "",
  117.                                     "%name%.getCurrentText()",
  118.                                     conn.getString("getCurrentText"));
  119.             connections.addElement(connection);
  120.  
  121.             getCurrentText.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  122.             md.addElement(getCurrentText);
  123.         } catch (Exception e) { throw new Error("getCurrentText:: " + e.toString()); }
  124.  
  125.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  126.         md.copyInto(rv);
  127.  
  128.         return rv;
  129.     }
  130.  
  131.     /**
  132.      * Returns descriptions of this bean's properties.
  133.      */
  134.     public PropertyDescriptor[] getPropertyDescriptors() {
  135.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  136.  
  137.         try{
  138.         PropertyDescriptor listItems = new PropertyDescriptor("listItems", beanClass);
  139.         listItems.setBound(true);
  140.         listItems.setConstrained(true);
  141.         listItems.setDisplayName(prop.getString("listItems"));
  142.  
  143.         PropertyDescriptor allowDynamicResizing = new PropertyDescriptor("allowDynamicResizing", beanClass);
  144.         allowDynamicResizing.setBound(true);
  145.         allowDynamicResizing.setConstrained(true);
  146.         allowDynamicResizing.setDisplayName(prop.getString("allowDynamicResizing"));
  147.  
  148.         PropertyDescriptor[] rv = {
  149.             listItems,
  150.             allowDynamicResizing};
  151.         return rv;
  152.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  153.     }
  154.  
  155.     private final static Class beanClass = ListSpinner.class;
  156.  
  157.     }    //  end of class ListSpinnerBeanInfo